package com.czk.ssamcplocalclient.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @Author: chenzhangkun
 * @CreateTime: 2025-11-03
 * @Description:
 * @Version: 1.0
 */
@RestController
public class McpClientController {

    @Resource(name = "qwenChatClient")
    private ChatClient chatClient;
    @Resource(name = "qwen")
    private ChatModel chatModel;

    /**
     * 使用mcp服务
     *
     * @param msg
     * @return
     */
    @GetMapping("/mcpclient/chat")
    public Flux<String> chat(@RequestParam(name = "msg", defaultValue = "成都") String msg) {

        return chatClient.prompt(msg)
                .stream()
                .content();
    }

    /**
     * 没有使用mcp服务
     *
     * @param msg
     * @return
     */
    @GetMapping("/mcpclient/chat2")
    public Flux<String> chat2(@RequestParam(name = "msg", defaultValue = "成都") String msg) {

        return chatModel.stream(msg);
    }

}
